package com.lxf.project.util;

public class DebugCAS implements Runnable{
    private volatile int value;
    public synchronized int compareAndSwap(int expectedValue, int newValue) {
        int oldValue = value;
        if (oldValue == expectedValue) {
            value = newValue;
            System.out.println("线程"+Thread.currentThread().getName()+"执行成功");
        }
        return oldValue;
    }
    public static void main(String[] args) throws InterruptedException {
 /*       DebugCAS r = new DebugCAS();
        r.value = 100;
        Thread t1 = new Thread(r,"Thread 1");
        Thread t2 = new Thread(r,"Thread 2");
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(r.value);
        ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();*/
//        ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
//        concurrentHashMap.put( "ytest",2323 );
//        ConcurrentLinkedQueue ConcurrentLinkedQueue;
//
//        int aa = 0;
//        for(int pp = aa,bb= pp;;) {
//            System.out.println(aa);
//            System.out.println(bb);
//            System.out.println(pp);
//        }

//        Integer aa=0;
//        Integer bb=aa;
//        Integer cc=bb;
//        System.out.println( Objects.equals( aa, bb ) );
//        System.out.println( Objects.equals( aa, cc ) );
//        List<String>
    }
    @Override
    public void run() {
        compareAndSwap(100, 150);
    }
}
